using System;
using System.Web.Core;

namespace Forum.Business
{
    public class Post : Entity
    {
        private Property<int> groupId = new Property<int>();
        private Property<int> sectionId = new Property<int>();
        private Property<int> threadId = new Property<int>();
        private Property<string> body = new Property<string>();
        private Property<int> authorId = new Property<int>();
        private Property<string> author = new Property<string>();
        private Property<DateTime> createDate = new Property<DateTime>();
        private int postIndex = 0;

        public Property<int> GroupId
        {
            get
            {
                return groupId;
            }
            set
            {
                groupId = value;
            }
        }
        public Property<int> SectionId
        {
            get
            {
                return sectionId;
            }
            set
            {
                sectionId = value;
            }
        }
        public Property<int> ThreadId
        {
            get
            {
                return threadId;
            }
            set
            {
                threadId = value;
            }
        }
        public Property<int> AuthorId
        {
            get
            {
                return authorId;
            }
            set
            {
                authorId = value;
            }
        }
        public Property<string> Author
        {
            get
            {
                return author;
            }
            set
            {
                author = value;
            }
        }
        public Property<string> Body
        {
            get
            {
                return body;
            }
            set
            {
                body = value;
            }
        }
        public Property<DateTime> CreateDate
        {
            get
            {
                return createDate;
            }
            set
            {
                createDate = value;
            }
        }
        public int PostIndex
        {
            get
            {
                return postIndex;
            }
            set
            {
                postIndex = value;
            }
        }

        public override bool IsOwner(User user)
        {
            if (user.EntityId.Value == AuthorId.Value)
            {
                return true;
            }
            return false;
        }
    }
}